<div class="item-from-row">
    <div class="ey-con ey-row mt10">
        <div class="item-from-flex">
            <div class="item-flex wb25">
                <div class="item-tit">
                    下载限制：
                </div>
            </div>
            <div class="item-flex-r wb75">
                <div class="select">
                    <select name="arc_level_id" id="arc_level_id">

                    </select>
                </div>
                <span class="err"></span>
                <p class="notic"></p>
            </div>
        </div>
    </div>

    <div class="ey-con ey-row mt10">
        <div class="item-from-flex">
            <div class="item-flex wb25">
                <div class="item-tit">
                    上传文件：
                </div>
            </div>
            <div class="item-flex-r wb75">
                <div class="layui-upload" id="download-layui-upload">
                    <button type="button" class="layui-btn layui-btn-normal none" id="buttonList" >选择多文件</button>
                    <label><input type="checkbox" value="1" onclick="ClickRemoteFile(this);">远程地址</label>
                    
                </div>
                <span class="err"></span>
                <p class="notic"></p>
            </div>
        </div>
        <div class="item-from-flex">
            <div class="layui-upload-list" style="overflow: auto;">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>文件名</th>
                        <th class="th_server_name" style="display: none;">服务器名称</th>
                        <th>大小</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="demoList"></tbody>
                </table>
            </div>
            <div style="display: none;" id='ClickRemoteFile'>
                <div id='Template20210507'>
            
                </div>
                <a onclick="GetTemplateAddr(2);" style="cursor: pointer;">
                    更多远程地址
                </a>
            </div>
            <button style="display:none;" type="button" class="layui-btn" id="buttonListAction">批量重传</button>
        </div>
    </div>
</div>
<script type="text/javascript">
    var admin_id = "{$Think.session.users_id|default='1'}";
    var t2_1598602098 = '';

    function search_mouseover(th)
    {
        var sinput_id = $(th).attr('data-sinput_id');
        $('#search_keywords_list_'+sinput_id).show();
        try{
            clearTimeout(t2_1598602098);
        }catch(e){}
    }

    function search_mouseout(th)
    {
        var sinput_id = $(th).attr('data-sinput_id');
        var setFunc = $("#search_keywords_list_"+sinput_id).hide();
        t2_1598602098 = setTimeout('"'+setFunc+'"',1000);
    }
    function select_sname(th) {
        var sinput_id = $(th).attr('data-sinput_id');
        var sname = $(th).attr('data-sname');
        $("#"+sinput_id).val(sname);
    }
    function searchServername(th) {
        var sinput_id = $(th).attr('id');
        $.ajax({
            type: "POST",
            url: "{:url('Download/search_servername')}",
            data: {keyword:'',_ajax:1},
            dataType: 'json',
            cache: false,
            success: function (res) {
                if(res.code == 1){
                    if (res.data.length > 0) {
                        var html='';
                        res.data.forEach(function(i,e) {
                            var e_num = e+1;
                            html += '<a href="javascript:void(0);" onclick="select_sname(this);" onmouseover="search_mouseover(this);" onmouseout="search_mouseout(this);" data-sname="'+i+'" data-sinput_id="'+sinput_id+'" style="cursor: pointer;">';
                            html += '<div class="number c'+e_num+'">'+e_num+'</div>';
                            html += '<div class="hottxt">'+i+'</div>';
                            html += '</a>';
                        });
                        // return false;

                        $('#search_keywords_list_'+sinput_id).html(html).show();
                    } else {
                        $('#search_keywords_list_'+sinput_id).hide();
                    }
                } else {
                    $('#search_keywords_list_'+sinput_id).hide();
                }
            }
        });
    }
    function round_num() {
        var num = '';
        for(var i=0;i<3;i++)
        {
            num+=Math.floor(Math.random()*10);
        }
        return num;
    }
    function judgeExt(ext) {
        var extArr = [];
        extArr = type20210507.split("|");
        var ext = ext.replace(".","");

        return extArr.indexOf(ext);
    }
    function cos_download__upload() {
        var cosFileObj = document.getElementById("cosFile").files;
        var formData = new FormData();
        formData.append('file_num', cosFileObj.length);
        for (var i = 0; i < cosFileObj.length; i++) {
            var file = cosFileObj[i];
            var fileName = file.name;
            var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
            var ext = judgeExt(fileExt);
            if (ext > -1) {
                // 追加显示在页面上
                var timestamp = new Date().getTime() + '-' + Math.ceil(Math.random()*100);
                var append_html = '';
                append_html += '<tr>';
                append_html += '<td>'+ file.name +'</td>';
                if (1 == servername_use20210507){
                    append_html += '<td class="th_server_name">';
                } else {
                    append_html += '<td class="th_server_name" style="display: none;">';
                }
                append_html += '<input type="text" name="fileupload[server_name][]" value="腾讯云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
                append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
                append_html += '</td>';
                append_html += '<td>'+ (file.size/1014).toFixed(1) +' KB</td>';
                append_html += '<td id="upload-'+ timestamp +'">上传腾讯云…请稍等</td>';
                append_html += '<td><button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</button>';
                append_html += '</td>';
                append_html += '</tr>';
                $("#demoList").append(append_html);

                // 表单提交数据
                formData.append('file_' + [i], cosFileObj[i]);
                formData.append('file_mime_' + [i], file.type);
                formData.append('file_name_' + [i], file.name);
                formData.append('file_size_' + [i], file.size);
                formData.append('file_ext_'  + [i], fileExt);
                formData.append('file_tdid_' + [i], "#upload-" + timestamp);
            } else {
                showErrorMsg('不支持选中的文件格式，仅支持' + type20210507);
            }
        }
        // 上传提示
        layer.msg('上传腾讯云……&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font id="upgrade_backup_speed">0.01</font>%，请勿刷新', {icon: 1, time: 3600000, shade: [0.2]});
        layer.load(3, {shade: [0.1,'#fff']});
        $.ajax({
            type: 'post',
            url : "{:url('plugins/Cos/cos_multiple_upload')}",
            data: formData,
            contentType: false,
            processData: false,
            dataType: 'json',
            xhr: function () {
                myXhr = $.ajaxSettings.xhr();
                if (myXhr.upload) {
                    myXhr.upload.addEventListener('progress', function(e) {
                        var curr = e.loaded;
                        var total = e.total;
                        var process = parseInt(curr / total * 100);
                        process = 100 == process ? 99 : process;
                        $('#upgrade_backup_speed').html(process);

                    });
                }
                return myXhr;
            },
            success: function(res) {
                layer.closeAll();
                try {
                    if (1 == res.code) {
                        var file_url = res.data.file_url;
                        $.each(file_url, function(i, item) {
                            var html = '';
                            html += '<input type="hidden" name="fileupload[file_url][]" value="'+ file_url[i] +'">';
                            html += '<input type="hidden" name="fileupload[file_mime][]" value="'+ res.data.file_mime[i] +'">';
                            html += '<input type="hidden" name="fileupload[file_name][]" value="'+ res.data.file_name[i] +'">';
                            html += '<input type="hidden" name="fileupload[file_size][]" value="'+ res.data.file_size[i] +'">';
                            html += '<input type="hidden" name="fileupload[file_ext][]" value="'+ res.data.file_ext[i] +'">';
                            $(res.data.file_tdid[i]).html('<span style="color: #5FB878;">上传成功</span>' + html);
                        });
                    } else {
                        showErrorAlert('接口超时，部分上传腾讯云失败，请移除未上传成功的文件重新上传。');
                    }
                } catch(e) {}
            },
            error: function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }
    function qny_download__upload() {
        var arr = [];
        for(var i = 0 ;i<document.getElementById("qnyFile").files.length;i++){
            file=document.getElementById("qnyFile").files[i];
            var fileName = file.name;
            var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
            var ext = judgeExt(fileExt);
            if (ext>-1) {
                var timestamp = new Date().getTime()+'-'+ Math.ceil(Math.random()*100);
                arr[i] = timestamp;
                var append_html = '';
                append_html += '<tr id="upload-'+ timestamp +'">';
                append_html += '<td>'+ file.name +'</td>';
                if (1 == servername_use20210507){
                    append_html += '<td class="th_server_name">';
                }else{
                    append_html += '<td class="th_server_name" style="display: none;">';
                }
                append_html += '<input type="text" name="fileupload[server_name][]" value="七牛云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
                append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
                append_html += '</td>';
                append_html += '<td>'+ (file.size/1014).toFixed(1) +' KB</td>';
                append_html += '<td>等待上传</td>';
                append_html += '<td><button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</button>';
                append_html += '</td>';
                append_html += '</tr>';
                $("#demoList").append(append_html);
            }else{
                showErrorMsg('不支持选中的文件格式,仅支持'+type20210507);
            }
        }

        var date = new Date();
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? '0' + m : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        $.ajax({
            type: 'POST',
            url: "{:url('plugins/Qiniuyun/qiniu_upload')}",
            data: {_ajax:1,down:1},
            dataType: "JSON",
            success: function(res1){
                if (1 == res1.code){
                    var token  = res1.data.token;
                    for(var i = 0 ;i<document.getElementById("qnyFile").files.length;i++) {
                        file = document.getElementById("qnyFile").files[i];

                        var fileName = file.name;
                        var formData = new FormData();
                        formData.append('token', token);
                        formData.append('file', file);
                        var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
                        var num = round_num();
                        var name = 'U'+admin_id+'-'+ new Date().getTime()+num+ fileExt;
                        fileName = res1.data.filePath + y + m + d + "/"+ name;
                        formData.append('key', fileName);
                        var tr = $("#upload-" + arr[i]);
                        new Promise(function() {
                            var tr = $("#upload-" + arr[i]);
                            var file_mime = file.type;
                            var file_name = file.name;
                            var file_size = file.size;
                            var file_ext = fileExt;
                            $.ajax({
                                url: res1.data.uphost,
                                type: 'POST',
                                dataType: 'JSON',
                                data: formData,
                                timeout: 1200000,
                                // async: false,
                                cache: false,
                                processData: false,
                                contentType: false,
                                xhr: function () {
                                    myXhr = $.ajaxSettings.xhr();
                                    if (myXhr.upload) {
                                        myXhr.upload.addEventListener('progress', function (e) {
                                            var curr = e.loaded;
                                            var total = e.total;
                                            process = parseInt(curr / total * 100);
                                            tr.children("td").eq(3).text('上传中...' + process + "%");
                                        });
                                    }
                                    return myXhr;
                                },
                                success: function (res2) {
                                    var video_url = res1.data.domain + "/" + res2.key;
                                    //
                                    var html = '';
                                    html += '<input type="hidden" name="fileupload[file_url][]" value="'+ video_url +'">';
                                    html += '<input type="hidden" name="fileupload[file_mime][]" value="'+ file_mime +'">';
                                    html += '<input type="hidden" name="fileupload[file_name][]" value="'+ file_name +'">';
                                    html += '<input type="hidden" name="fileupload[file_ext][]" value="'+ file_ext +'">';
                                    html += '<input type="hidden" name="fileupload[file_size][]" value="'+ file_size +'">';

                                    var tds = tr.children();
                                    tds.eq(3).html('<span style="color: #5FB878;">上传成功</span>');
                                    tds.eq(4).html('<span class="layui-btn layui-btn-xs layui-btn-danger" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</span>'+html);

                                },
                                error: function (e) {
                                    showErrorMsg(e.responseText);
                                    return false;
                                }
                            });
                        })
                    }
                }else{
                    showErrorMsg(res1.msg);
                }
            },
            error: function(e){
                showErrorMsg(e.responseText);
            }
        });

    }

    function oss_download__upload() {
        var arr = [];
        for(var i = 0 ;i<document.getElementById("ossFile").files.length;i++){
            file=document.getElementById("ossFile").files[i];

            var fileName = file.name;
            var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
            var ext = judgeExt(fileExt);
            if (ext>-1) {
                //此时取出这个文件进行处理，这里只是显示文件名
                var timestamp = new Date().getTime() + '-' + Math.ceil(Math.random()*100);
                arr[i] = timestamp;
                var append_html = '';
                append_html += '<tr id="upload-'+ timestamp +'">';
                append_html += '<td>'+ file.name +'</td>';
                if (1 == servername_use20210507){
                    append_html += '<td class="th_server_name">';
                }else{
                    append_html += '<td class="th_server_name" style="display: none;">';
                }
                append_html += '<input type="text" name="fileupload[server_name][]" value="阿里云服务器" id="severname_qiniuyun_'+i+'" onclick="searchServername(this);" autocomplete="off">';
                append_html += '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_qiniuyun_'+i+'"></div>';
                append_html += '</td>';
                append_html += '<td>'+ (file.size/1014).toFixed(1) +' KB</td>';
                append_html += '<td>等待上传</td>';
                append_html += '<td><button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</button>';
                append_html += '</td>';
                append_html += '</tr>';
                $("#demoList").append(append_html);
            }else{
                showErrorMsg('不支持选中的文件格式,仅支持'+type20210507);
            }
        }
        var date = new Date();
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? '0' + m : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;

        $.ajax({
            type: 'POST',
            url : "{:url('plugins/AliyunOss/oss_upload')}",
            data: {_ajax:1,down:1},
            dataType: "JSON",
            success: function(res1){
                if (1 == res1.code){
                    var accessid = res1.data.accessid;
                    var policy = res1.data.policy;
                    var signature = res1.data.signature;
                    var filePath = res1.data.filePath;
                    for(var i = 0 ;i<document.getElementById("ossFile").files.length;i++) {
                        file = document.getElementById("ossFile").files[i];
                        var fileName = file.name;

                        var request = new FormData();
                        request.append("OSSAccessKeyId",accessid);
                        request.append("policy",policy);
                        request.append("Signature",signature);
                        request.append("success_action_status",201);

                        var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
                        var num = round_num();
                        //存储文件名
                        var name = 'U'+admin_id+'-'+ new Date().getTime()+num+ fileExt;
                        fileName = filePath + y + m + d + "/"+ name;

                        request.append("key", fileName);
                        request.append('file', file);

                        var tr = $("#upload-" + arr[i]);
                        new Promise(function() {
                            var tr = $("#upload-" + arr[i]);
                            var file_mime = file.type;
                            var file_name = file.name;
                            var file_size = file.size;
                            var file_ext = fileExt;
                            $.ajax({
                                url: res1.data.host,
                                data: request,
                                processData: false,
                                cache: false,
                                contentType: false,
                                dataType: 'xml',
                                type : 'post',
                                xhr: function () {
                                    myXhr = $.ajaxSettings.xhr();
                                    if (myXhr.upload) {
                                        myXhr.upload.addEventListener('progress', function (e) {
                                            var curr = e.loaded;
                                            var total = e.total;
                                            process = parseInt(curr / total * 100);
                                            tr.children("td").eq(3).text('上传中...' + process + "%");
                                        });
                                    }

                                    return myXhr;
                                },
                                success: function (res2) {
                                    var res = $(res2).find('PostResponse');
                                    if (res) {
                                        var key = res.find('Key').text();
                                        var video_url = res1.data.domain + "/" + key;
                                        var html = '';
                                        html += '<input type="hidden" name="fileupload[file_url][]" value="' + video_url + '">';
                                        html += '<input type="hidden" name="fileupload[file_mime][]" value="' + file_mime + '">';
                                        html += '<input type="hidden" name="fileupload[file_name][]" value="' + file_name + '">';
                                        html += '<input type="hidden" name="fileupload[file_ext][]" value="' + file_ext + '">';
                                        html += '<input type="hidden" name="fileupload[file_size][]" value="' + file_size + '">';

                                        var tds = tr.children();
                                        tds.eq(3).html('<span style="color: #5FB878;">上传成功</span>');
                                        tds.eq(4).html('<span class="layui-btn layui-btn-xs layui-btn-danger" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</span>' + html);
                                    }

                                },
                                error: function (e) {
                                    showErrorMsg(e.responseText);
                                    return false;
                                }
                            });
                        })
                    }
                }else{
                    showErrorMsg(res1.msg);
                }
            },
            error: function(e){
                showErrorMsg(e.responseText);
            }
        });
    }

    // 远程/本地上传文件切换
    function ClickRemoteFile(obj)
    {
        if ($(obj).is(':checked')) {
            var length = $(".template_div20210507").length;
            if (0 == length){
                var template_div20210507_html = '';
                for (var i=1;i<4;i++) {
                    template_div20210507_html += '<div class="template_div20210507">远程地址'+i+'：<input type="text" name="remote_file[]" value="" placeholder="http://" style="width: 50%;">\n' ;
                    $.each(attr_field20210507, function (index, value) {
                        var field_use_style = '';
                        if(1 != value.field_use){
                            field_use_style = ' style="display: none;" ';
                        }
                        if('server_name' == value.field_name){
                            template_div20210507_html += '<span class="ey_'+value.field_name+'" '+field_use_style+'>\n' +
                                '<span class="title_'+value.field_name+'">'+value.field_title+'</span>：' +
                                '<input type="text" name="'+value.field_name+'[]" id="'+value.field_name+'_remote_'+i+'" style="width: 7%;" onclick="searchServername(this);" autocomplete="off" value="'+default_servername20210507+'" >\n' +
                                '<div class="help-hot-list remote-hot-list" style="display: none;" data-test_val="5434" id="search_keywords_list_'+value.field_name+'_remote_'+i+'"></div>\n' +
                                '</span>\n' ;
                        }else{
                            template_div20210507_html += '<span class="ey_'+value.field_name+'" '+field_use_style+'>\n' +
                                '<span class="title_'+value.field_name+'">'+value.field_title+'</span>：' +
                                '<input type="text" name="'+value.field_name+'[]" id="'+value.field_name+'_remote_'+i+'" style="width: 7%;"></span>\n' ;
                        }
                    });

                    template_div20210507_html += '</div>';
                }
                $("#Template20210507").html(template_div20210507_html);
            }
            $('#ClickRemoteFile').show();
        } else {
            $('#ClickRemoteFile').hide();
        }
    }

    // 获取模板属性数据
    function GetTemplateAddr(num){
        if (!num) {
            num = 1;
        }
        $.ajax({
            url: "{:url('Download/get_template', ['_ajax'=>1])}",
            data: {num:num},
            type:'post',
            dataType:'json',
            success: function(res){
                // 拼装模板属性并追加
                AddTemplateAddr(num,res.data);
            },
        });
    }

    // 删除对应的文件及文件信息
    function DeleteFile(obj){
        var filenames = $(obj).next().val();
        $(obj).parent().parent().remove();
        if (filenames) {
            var type20210507 = $('#download-layui-upload').attr('data-type');
            var url = '';
            if ('qny' == type20210507) {
                url = "{:url('plugins/Qiniuyun/deleteQny')}";
            }else if ('oss' == type20210507) {
                url = "{:url('plugins/AliyunOss/deleteOss')}";
            }else if ('cos' == type20210507) {
                url = "{:url('plugins/Cos/deleteCos')}";
            }else{
                url = "{:url('user/Uploadify/del_local')}";
            }
            $.ajax({
                type: 'GET',
                url: url,
                data: {_ajax: 1, filenames: filenames},
                success: function (res1) {
                }
            });
        }
    }

    // 拼装模板属性并追加
    function AddTemplateAddr(num,data){
        if (!num) {
            num = 1;
        }
        var SerialNum = $('#Template20210507 div.template_div20210507').length;
        var default_servername = default_servername20210507;
        var html_div = [];
        if (num > 1) {
            for (var i = 0; i < num; i++) {
                SerialNum++;
                html_div +=['<div class="template_div20210507">远程地址'+SerialNum+'：<input type="text" name="remote_file[]" value="" placeholder="http://" style="width: 50%;"> '];

                if (data) {
                    for (var j = 0; j < data.length; j++) {
                        if (data[j]['field_name'] == 'server_name') {
                            if (data[j]['field_use'] == 1){
                                html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
                            }else {
                                html_div += ['<span  style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
                            }
                            html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>：<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_remote_'+SerialNum+'" style="width: 7%;" onclick="searchServername(this);" autocomplete="off" value="'+default_servername+'">'+
                            '<div class="help-hot-list" style="display: none;" id="search_keywords_list_'+data[j]['field_name']+'_remote_'+SerialNum+'"></div>'+
                            '</span>'];
                        }else{
                            if (data[j]['field_use'] == 1){
                                html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
                            }else {
                                html_div += ['<span  style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
                            }
                            html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>：<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_'+SerialNum+'" style="width: 7%;"></span>'];
                        }
                    }
                }

                html_div +=['</div>'];
            }
        }else{
            SerialNum++;
            html_div +=
                ['<div class="template_div20210507">远程地址'+SerialNum+'：<input type="text" name="remote_file[]" value="" placeholder="http://" style="width: 50%;">'];
            if (data) {
                for (var j = 0; j < data.length; j++) {
                    if (data[j]['field_name'] == 'server_name') {
                        if (data[j]['field_use'] == 1){
                            html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
                        }else {
                            html_div += ['<span  style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
                        }
                        html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>：<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_remote_'+SerialNum+'" style="width: 7%;" onclick="searchServername(this);" autocomplete="off" value="'+default_servername+'">'+
                        '<div class="help-hot-list" style="display: none;" id="search_keywords_list_'+data[j]['field_name']+'_remote_'+SerialNum+'"></div>'+
                        '</span>'];
                    }else{
                        if (data[j]['field_use'] == 1){
                            html_div += ['<span class="ey_' + data[j]['field_name'] + '"> '];
                        }else {
                            html_div += ['<span  style="display:none;" class="ey_' + data[j]['field_name'] + '"> '];
                        }
                        html_div +=['<span class="title_'+data[j]['field_name']+'"> '+data[j]['field_title']+'</span>：<input type="text" name="'+data[j]['field_name']+'[]" id="'+data[j]['field_name']+'_'+SerialNum+'" style="width: 7%;"></span>'];
                    }
                }
            }
            html_div += ['</div>'];
        }

        // 追加html
        $('#Template20210507').append(html_div);
    }

    // 文件上传JS
    layui.use('upload', function(){
        var $ = layui.jquery,upload = layui.upload;
        // 多文件列表示例
        var demoListView = $('#demoList'),uploadListIns = upload.render({
            elem: '#buttonList',
            url: "{:url('user/Uploadify/DownloadUploadFile')}",
            accept: 'file',
            exts: type20210507,
            multiple: true,
            auto: true,
            bindAction: '#buttonListAction',
            choose: function(obj){
                // 将每次选择的文件追加到文件队列
                var files = this.files = obj.pushFile();
                // 读取本地文件
                obj.preview(function(index, file, result){
                    if (1 == servername_use20210507) {
                        var tr = $(
                            [
                                '<tr id="upload-' + index + '">',
                                '<td>' + file.name + '</td>',
                                '<td  class="th_server_name"><input type="text" name="fileupload[server_name][]" value="'+default_servername20210507+'" id="severname_local_' + index + '" onclick="searchServername(this);" autocomplete="off" style="width: 75px;">',
                                '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_local_' + index + '"></div>',
                                '</td>',
                                '<td>' + (file.size / 1014).toFixed(1) + ' KB</td>',
                                '<td>等待上传</td>',
                                '<td>',
                                // '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>',
                                '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;">移除</button>',
                                '</td>',
                                '</tr>'
                            ].join(''));
                    }else{
                        var tr = $(
                            [
                                '<tr id="upload-' + index + '">',
                                '<td>' + file.name + '</td>',
                                '<td  class="th_server_name" style="display: none;"><input type="text" name="fileupload[server_name][]" value="'+default_servername20210507+'" id="severname_local_' + index + '" onclick="searchServername(this);" autocomplete="off" style="width: 75px;">',
                                '<div class="help-hot-list" style="display: none;" id="search_keywords_list_severname_local_' + index + '"></div>',
                                '</td>',
                                '<td>' + (file.size / 1014).toFixed(1) + ' KB</td>',
                                '<td>等待上传</td>',
                                '<td>',
                                // '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>',
                                '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete" style="line-height:unset;height: unset;">移除</button>',
                                '</td>',
                                '</tr>'
                            ].join(''));
                    }

                    // 单个重传
                    tr.find('.demo-reload').on('click', function(){
                        obj.upload(index, file);
                    });

                    // 删除
                    tr.find('.demo-delete').on('click', function(){
                        // 删除对应的文件
                        delete files[index];
                        tr.remove();
                        // 清空 input file 值，以免删除后出现同名文件不可选
                        uploadListIns.config.elem.next()[0].value = '';
                    });
                    demoListView.append(tr);
                });
            },
            done: function(res, index, upload){
                if(res.code == 1){
                    // 上传成功
                    var html = '';
                    html += '<input type="hidden" name="fileupload[file_url][]" value="'+res.file_url+'">';
                    html += '<input type="hidden" name="fileupload[file_mime][]" value="'+res.file_mime+'">';
                    html += '<input type="hidden" name="fileupload[file_name][]" value="'+res.file_name+'">';
                    html += '<input type="hidden" name="fileupload[file_ext][]" value="'+res.file_ext+'">';
                    html += '<input type="hidden" name="fileupload[file_size][]" value="'+res.file_size+'">';
                    html += '<input type="hidden" name="fileupload[uhash][]" value="'+res.uhash+'">';
                    html += '<input type="hidden" name="fileupload[md5file][]" value="'+res.md5file+'">';

                    var tr = demoListView.find('tr#upload-'+ index),
                        tds = tr.children();
                    tds.eq(0).html(res.file_name);
                    tds.eq(3).html('<span style="color: #5FB878;">'+res.msg+'</span>');
                    tds.eq(4).html('<span class="layui-btn layui-btn-xs layui-btn-danger" style="line-height:unset;height: unset;" onclick="DeleteFile(this);">移除</span>'+html);

                    // 清空操作
                    return delete this.files[index];// 删除文件队列已经上传成功的文件
                }
                this.error(res, index, upload);
            },
            error: function(res, index, upload){
                var tr = demoListView.find('tr#upload-'+ index),
                    tds = tr.children();
                tds.eq(3).html('<span style="color: #FF5722;">'+res.msg+'</span>');
            }
        });
    });
</script>